﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Main.master" CodeBehind="StockFilter2.aspx.cs" Inherits="StockCrawler.StockFilter2" %>

<%@ Register Assembly="DevExpress.Web.v14.2, Version=14.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Data.Linq" TagPrefix="dx" %>


<asp:Content ID="Content" ContentPlaceHolderID="MainContent" runat="server">
    <link rel="stylesheet" type="text/css" href="Content/StockFilter.css" />
    <script type="text/javascript">
        var order;
        function onSorting(s, e) {
            order = order == "ASC" ? "DESC" : "ASC";
            e.cancel = true;
            s.PerformCallback("SORT|" + e.column.fieldName + "|" + order);
        }

        function getPaging(s, e) {
            if (typeof (detailGridView) != 'undefined' && e.visibleIndex != -1) {
                detailGridView.PerformCallback("PAGING");
                Callback1.PerformCallback(e.visibleIndex);
            }
        }

        function getIndex(s, e) {
            if (typeof (detailGridView) != 'undefined' && e.visibleIndex != -1) {
                detailGridView.PerformCallback("INDEX|" + e.visibleIndex);
                Callback1.PerformCallback(e.visibleIndex);
            }
        }

        function RefreshData(s, e) {
            var isIncrease = false;
            if (isIncrease.Checked)
                isIncrease = true;

            var numDays = cboNumDaysClient.GetValue();
            if (typeof (detailGridView) != 'undefined')
                detailGridView.PerformCallback("REFRESH|" + isIncrease + "|" + numDays);
        }

        function OnCallbackComplete(s, e) {
            //var pricebox1 = document.get.getElementById("divInfo");
            //pricebox1.InnerHTML = e.result;
            //alert(e.result);
            //alert("Hello! I am an alert box!!");
            lblInfo.SetText(e.result);
        }
    </script>

    <div style="margin: 10px 0px 10px 20px;">
        <%--<table style="width: 100%;">
            <tr>
                <td style="width: 60px">
                    <dx:ASPxRadioButton ID="rbnAll" ClientInstanceName="rbnAllClient" Text="Tất cả" runat="server" GroupName="1" Style="height: 19px" AutoPostBack="True" OnCheckedChanged="rbnAll_CheckedChanged">
                    </dx:ASPxRadioButton>
                </td>
                <td style="width: 60px">
                    <dx:ASPxRadioButton ID="rbnCE" ClientInstanceName="rbnCEClient" Text="Trần" runat="server" GroupName="1" AutoPostBack="True" OnCheckedChanged="rbnCE_CheckedChanged" Height="19px">
                    </dx:ASPxRadioButton>
                </td>
                <td style="width: 60px">
                    <dx:ASPxRadioButton ID="rbnFL" ClientInstanceName="rbnFLClient" Text="Sàn" runat="server" GroupName="1" AutoPostBack="True" OnCheckedChanged="rbnFL_CheckedChanged">
                    </dx:ASPxRadioButton>
                </td>
                <td style="width: 60px">
                    <dx:ASPxRadioButton ID="rbnIncrease" ClientInstanceName="rbnIncreaseClient" Text="Tăng" runat="server" GroupName="1" OnCheckedChanged="rbnIncrease_CheckedChanged" Style="height: 19px" AutoPostBack="True">
                    </dx:ASPxRadioButton>
                </td>
                <td style="width: 90px">
                    <dx:ASPxRadioButton ID="rbnDecrease" ClientInstanceName="rbnDecreaseClient" Text="Giảm" runat="server" GroupName="1" OnCheckedChanged="rbnDecrease_CheckedChanged" AutoPostBack="True">
                    </dx:ASPxRadioButton>
                </td>
                <td style="width: 130px">
                    <dx:ASPxLabel ID="lblNumDaysBefore" runat="server" Text="Số ngày giảm liên tục">
                    </dx:ASPxLabel>
                </td>
                <td style="width: 50px">
                    <dx:ASPxComboBox ID="cboNumDaysBefore" Width="40px" ClientInstanceName="cboNumDaysClient" runat="server" SelectedIndex="2" Style="margin-left: 0px" OnSelectedIndexChanged="cboNumDaysBefore_SelectedIndexChanged" AutoPostBack="True">
                        <Items>
                            <dx:ListEditItem Text="1" Value="1" />
                            <dx:ListEditItem Text="2" Value="2" />
                            <dx:ListEditItem Text="3" Value="3" Selected="True" />
                            <dx:ListEditItem Text="4" Value="4" />
                            <dx:ListEditItem Text="5" Value="5" />
                            <dx:ListEditItem Text="6" Value="6" />
                            <dx:ListEditItem Text="7" Value="7" />
                            <dx:ListEditItem Text="8" Value="8" />
                            <dx:ListEditItem Text="9" Value="9" />
                            <dx:ListEditItem Text="10" Value="10" />
                        </Items>
                    </dx:ASPxComboBox>
                </td>
                <td style="width: 150px">
                    <dx:ASPxCheckBox ID="chkIncludeNoneChangeBefore" runat="server" Text="Gồm thay đổi = 0" AutoPostBack="True" OnCheckedChanged="chkIncludeNoneChangeBefore_CheckedChanged">
                    </dx:ASPxCheckBox>
                </td>
                <td style="width: 130px">
                    <dx:ASPxLabel ID="lblNumDaysAfter" runat="server" Text="Sau khi tăng liên tục">
                    </dx:ASPxLabel>
                </td>
                <td style="width: 50px">
                    <dx:ASPxComboBox ID="cboNumDaysAfter" Width="40px" ClientInstanceName="cboNumDaysClient" runat="server" SelectedIndex="2" Style="margin-left: 0px" AutoPostBack="True" OnSelectedIndexChanged="cboNumDaysAfter_SelectedIndexChanged">
                        <Items>
                            <dx:ListEditItem Text="0" Value="0" Selected="True" />
                            <dx:ListEditItem Text="1" Value="1" />
                            <dx:ListEditItem Text="2" Value="2" />
                            <dx:ListEditItem Text="3" Value="3" />
                            <dx:ListEditItem Text="4" Value="4" />
                            <dx:ListEditItem Text="5" Value="5" />
                            <dx:ListEditItem Text="6" Value="6" />
                            <dx:ListEditItem Text="7" Value="7" />
                            <dx:ListEditItem Text="8" Value="8" />
                            <dx:ListEditItem Text="9" Value="9" />
                            <dx:ListEditItem Text="10" Value="10" />
                        </Items>
                    </dx:ASPxComboBox>
                </td>
                <td style="width: 150px">
                    <dx:ASPxCheckBox ID="chkIncludeNoneChangeAfter" runat="server" Text="Gồm thay đổi = 0" AutoPostBack="True" OnCheckedChanged="chkIncludeNoneChangeAfter_CheckedChanged">
                    </dx:ASPxCheckBox>
                </td>
                <td style="width: 120px">
                    <dx:ASPxLabel ID="ASPxLabel4" runat="server" Text="Khối lượng giao dịch">
                    </dx:ASPxLabel>
                </td>
                <td style="width: 120px">
                    <dx:ASPxComboBox ID="cboVolumnRange" Width="100px" ClientInstanceName="cboKLGDClient" runat="server" SelectedIndex="2" Style="margin-left: 0px" AutoPostBack="True" OnSelectedIndexChanged="cboVolumnRange_SelectedIndexChanged">
                        <Items>
                            <dx:ListEditItem Text="All" Value="klgd_khop_lenh >= 0" />
                            <dx:ListEditItem Text="> 1,000" Value="klgd_khop_lenh >= 1000" Selected="True" />
                            <dx:ListEditItem Text="> 10,000" Value="klgd_khop_lenh >= 10000" />
                            <dx:ListEditItem Text="> 100,000" Value="klgd_khop_lenh >= 100000" />
                        </Items>
                    </dx:ASPxComboBox>
                </td>
                <td style="width: 90px">
                    <dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="Giá trị thay đổi">
                    </dx:ASPxLabel>
                </td>
                <td>
                    <dx:ASPxComboBox ID="cboChangedRange" Width="70px" ClientInstanceName="cboKLGDClient" runat="server" SelectedIndex="2" Style="margin-left: 0px" AutoPostBack="True" OnSelectedIndexChanged="cboChangedRange_SelectedIndexChanged">
                        <Items>
                            <dx:ListEditItem Text="All" Value="abs(thay_doi) >= 0" Selected="True" />
                            <dx:ListEditItem Text=">= 0.5" Value="abs(thay_doi) >= 0.5" />
                            <dx:ListEditItem Text=">= 1" Value="abs(thay_doi) >= 1.0" />
                        </Items>
                    </dx:ASPxComboBox>
                </td>
                <td>
                    <div id="divInfo" runat="server" style="height: 30px;">
                    </div>
                </td>
            </tr>
        </table>--%>
    </div>
    <div style="height: 90%;">
        <dx:ASPxSplitter ID="ASPxSplitter2" runat="server" Height="100%">
            <Styles>
                <Pane>
                    <Paddings Padding="0px" />
                </Pane>
            </Styles>
            <Panes>
                <dx:SplitterPane MinSize="400px" Size="430" Name="stockContainer" ShowCollapseBackwardButton="True">
                    <ContentCollection>
                        <dx:SplitterContentControl runat="server">
                            <dx:ASPxGridView ID="ASPxGridView1" Width="100%" KeyFieldName="id_stock" runat="server" DataSourceID="LinqServerModeDataSourceStock" AutoGenerateColumns="False" OnDataBound="ASPxGridView1_DataBound">
                                <%--<Settings ShowFilterRow="True" ShowFilterRowMenu="True" ShowFooter="True" VerticalScrollBarMode="Auto" HorizontalScrollBarMode="Auto" VerticalScrollableHeight="455" />--%>
                                <ClientSideEvents SelectionChanged="getIndex"/>
                                <Columns>
                                    <dx:GridViewDataTextColumn Caption="ID" FieldName="id_stock" ShowInCustomizationForm="True" Visible="False" VisibleIndex="0">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataCheckColumn VisibleIndex="1" FieldName="isRemark" Caption="#"  Width="40">
                                        <DataItemTemplate>
                                            <dx:ASPxCheckBox ID="chkIsRemark" ClientInstanceName="chkIsRemarkClient" runat="server" AutoPostBack="true" Checked='<%# Eval("isRemark") %>' OnCheckedChanged="chkIsRemark_CheckedChanged">
                                            </dx:ASPxCheckBox>
                                        </DataItemTemplate>
                                    </dx:GridViewDataCheckColumn>
                                    <dx:GridViewDataTextColumn Caption="Mã" FieldName="code" ShowInCustomizationForm="True" VisibleIndex="1" Width="60">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn Caption="Sàn" FieldName="stockexchange_name" ReadOnly="True" VisibleIndex="2" Width="50">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn Caption="Công ty" FieldName="name" ShowInCustomizationForm="True" VisibleIndex="3" Width="200px">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn FieldName="eps" ReadOnly="True" VisibleIndex="4" Width="40">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn FieldName="pe" ReadOnly="True" VisibleIndex="5" Width="40">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn FieldName="bv" ReadOnly="True" VisibleIndex="6" Width="40">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn FieldName="klcp_niemyet" ReadOnly="True" VisibleIndex="7" Width="90">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn FieldName="klcp_luuhanh" ReadOnly="True" VisibleIndex="8" Width="90">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn FieldName="vcsh" ReadOnly="True" VisibleIndex="9" Width="90">
                                    </dx:GridViewDataTextColumn>
                                </Columns>
                                <SettingsBehavior AllowFocusedRow="true" ProcessFocusedRowChangedOnServer="True" AllowSelectByRowClick="True" AllowSelectSingleRowOnly="True" />
                                <%--<SettingsPager Mode="ShowAllRecords" />--%>
                                <SettingsPager PageSize="20">
                                    <PageSizeItemSettings Items="20, 50, 100" Visible="True">
                                    </PageSizeItemSettings>
                                </SettingsPager>
                                <Settings VerticalScrollBarMode="Auto"  HorizontalScrollBarMode="Auto"  VerticalScrollableHeight="430" />
                                <Border BorderWidth="0px">
                                </Border>
                                <Settings ShowFilterRow="True"/>
                            </dx:ASPxGridView>
                            <dx:LinqServerModeDataSource ID="LinqServerModeDataSourceStock" runat="server" ContextTypeName="StockCrawlerLib.StockDataClassesDataContext" OnSelecting="LinqServerModeDataSourceStock_Selecting" />
                        </dx:SplitterContentControl>
                    </ContentCollection>
                </dx:SplitterPane>
                <dx:SplitterPane MinSize="350px">
                    <ContentCollection>
                        <dx:SplitterContentControl runat="server">
                            <div id="pricebox" runat="server" style="height: 30px; background-color: #1D1D1D; color: white">
                                <dx:ASPxLabel ID="lblInfo" runat="server" ClientInstanceName="lblInfo" >
                                </dx:ASPxLabel>
                            </div>
                            <div>
                                <dx:ASPxGridView ID="gridViewHistory" ClientInstanceName="detailGridView" Width="100%" runat="server" AutoGenerateColumns="false" KeyFieldName="id_stock" OnCustomCallback="gridViewHistory_CustomCallback" OnHtmlDataCellPrepared="gridViewHistory_HtmlDataCellPrepared">
                                    <Columns>
                                        <dx:GridViewDataDateColumn FieldName="stockexchange_name" Visible="false" VisibleIndex="1" Width="80" Caption="Ngày GD" SortOrder="Descending">
                                        </dx:GridViewDataDateColumn>
                                        <dx:GridViewDataDateColumn FieldName="ngay_giao_dich" VisibleIndex="2" Width="80" Caption="Ngày GD" SortOrder="Descending">
                                        </dx:GridViewDataDateColumn>
                                        <dx:GridViewDataTextColumn FieldName="gia_tran" VisibleIndex="3" Width="40" Caption="Trần">
                                            <PropertiesTextEdit DisplayFormatString="#,##0.0" />
                                            <CellStyle ForeColor="Magenta">
                                            </CellStyle>
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="gia_san" VisibleIndex="4" Width="40" Caption="Sàn">
                                            <PropertiesTextEdit DisplayFormatString="#,##0.0" />
                                            <CellStyle ForeColor="#66CCFF">
                                            </CellStyle>
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="gia_tham_chieu" VisibleIndex="5" Width="40" Caption="TC">
                                            <PropertiesTextEdit DisplayFormatString="#,##0.0" />
                                            <CellStyle ForeColor="#F7FF31">
                                            </CellStyle>
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="gia_dong_cua" VisibleIndex="6" Width="65" Caption="Đóng cửa">
                                            <PropertiesTextEdit DisplayFormatString="#,##0.0" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="thay_doi" VisibleIndex="7" Width="40" Caption="+/-">
                                            <PropertiesTextEdit DisplayFormatString="#0.0" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="thay_doi_percent" VisibleIndex="8" Width="40" Caption="%">
                                            <%--<PropertiesTextEdit DisplayFormatString="#,###.#%" />--%>
                                        </dx:GridViewDataTextColumn>
                                        <%--<dx:GridViewDataTextColumn FieldName="gia_mo_cua" VisibleIndex="9" Width="50" Caption="Mở cửa">
                                            <PropertiesTextEdit DisplayFormatString="#,##0.0" />
                                        </dx:GridViewDataTextColumn>--%><%--<dx:GridViewDataTextColumn FieldName="gia_cao_nhat" VisibleIndex="10" Width="65" Caption="Cao nhất">
                                            <PropertiesTextEdit DisplayFormatString="#,##0.0" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="gia_thap_nhat" VisibleIndex="11" Width="65" Caption="Thấp nhất">
                                            <PropertiesTextEdit DisplayFormatString="#,##0.0" />
                                        </dx:GridViewDataTextColumn>--%>
                                        <dx:GridViewDataTextColumn FieldName="klgd_khop_lenh" VisibleIndex="12" Width="80" Caption="KLGD">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="gtgd_khop_lenh" VisibleIndex="13" Width="110" Caption="GTGD">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="so_lenh_mua" VisibleIndex="14" Width="70" Caption="Lệnh mua">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="kl_dat_mua" VisibleIndex="15" Width="80" Caption="KL đặt mua">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="so_lenh_ban" VisibleIndex="16" Width="70" Caption="Lệnh bán">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="kl_dat_ban" VisibleIndex="17" Width="80" Caption="KL đặt bán">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="klgd_thoa_thuan" VisibleIndex="18" Width="90" Caption="KL thỏa thuận">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="klgd_nn_mua" VisibleIndex="19" Width="70" Caption="NN mua">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="klgd_nn_ban" VisibleIndex="20" Width="70" Caption="NN bán">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="klsh_nn_percent" VisibleIndex="21" Width="50" Caption="% NN" />
                                        <dx:GridViewDataTextColumn FieldName="klsh_nn_con_lai" VisibleIndex="22" Width="100" Caption="Room còn">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                        <dx:GridViewDataTextColumn FieldName="klsh_nn" VisibleIndex="23" Width="100" Caption="Room">
                                            <PropertiesTextEdit DisplayFormatString="#,###" />
                                        </dx:GridViewDataTextColumn>
                                    </Columns>
                                    <ClientSideEvents ColumnSorting="onSorting" />
                                    <SettingsBehavior AllowSelectByRowClick="true" />
                                    <Settings VerticalScrollBarMode="Auto" HorizontalScrollBarMode="Auto" VerticalScrollableHeight="450" />
                                    <SettingsPager Mode="ShowAllRecords" />
                                    <Styles>
                                        <Row BackColor="#1D1D1D" ForeColor="White">
                                        </Row>
                                    </Styles>
                                </dx:ASPxGridView>
                                //
                            </div>
                        </dx:SplitterContentControl>
                    </ContentCollection>
                </dx:SplitterPane>
            </Panes>
        </dx:ASPxSplitter>
        <dx:ASPxCallback ID="ASPxCallback1" runat="server" ClientInstanceName="Callback1" OnCallback="ASPxCallback1_Callback">
            <ClientSideEvents CallbackComplete="OnCallbackComplete" />
        </dx:ASPxCallback>
    </div>
</asp:Content>

